package org.activequant.data.retrieval.ib;

import java.io.Serializable;

import org.activequant.core.types.TimeStamp;

public class IBNewsBulletin implements Serializable{
	
	public IBNewsBulletin(long id, int msgType, TimeStamp stamp, String message, String exchange) {
		super();
		this.id = id;
		this.msgType = msgType;
		this.stamp = stamp;
		this.message = message;
		this.exchange = exchange;
	}
	private static final long serialVersionUID = 6589581204458930707L;
	/**
	 * private Long id;
	 */
	private Long id;
	/**
	 * private TimeStamp stamp;
	 */
	private TimeStamp stamp; 
	
	private Integer msgType; 
	
	private String message;
	
	private String exchange;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	public Integer getMsgType() {
		return msgType;
	}

	public void setMsgType(Integer msgType) {
		this.msgType = msgType;
	}

	public TimeStamp getStamp() {
		return stamp;
	}

	public void setStamp(TimeStamp stamp) {
		this.stamp = stamp;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getExchange() {
		return exchange;
	}

	public void setExchange(String exchange) {
		this.exchange = exchange;
	}
    
	@Override
	public String toString() {
		StringBuffer result=new StringBuffer("message=\""+message+"\"");
		if(msgType==1){
			result.append(" type=REGULAR");
		}else if(msgType==2){
			result.append(" type=EXCHANGE_NOT_AVAILABLE");
		}else if(msgType==3){
			result.append(" type=EXCHANGE_AVAILABLE");
		}
		
		if(exchange!=null){
			result.append(" exchange="+exchange);
		}
		result.append(" received="+stamp.getDate());
		result.append(" msgId="+id);
		return result.toString();
	}
}
